<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box" class="abc">
      hello
      <div id="box1" class="abcd">
        <p>this is tag p</p>
        <ul id="list">
          <li>1</li>
          <li id="li2">2</li>
          <li>3</li>
          <li>4</li>
        </ul>
      </div>
    </div>

    <script>
      /*
      closest
      1. 使用参数选择器匹配元素
      2. 匹配结果中，亲缘关系近的被选中，返回选中元素对象
      */
      const li2 = document.getElementById("li2");
      console.log(li2.closest(".abc"));
    </script>
  </body>
</html>
